home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / element.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  6KB  |  160 lines

  1. #include "element.h"
  2. #include "patterns.h"
  3. #include "khbgi.h"
  4.  
  5. void Element::show()
  6.     {
  7.     setcolor(pColorSet->colors.ATTR_COLOR);
  8.     setlinestyle(SOLID_LINE, 1, 1);
  9.     rect r = tog ? rectangle : screenRect(rectangle);
  10.     r.corner -= loc(2, 2);
  11.     int x = (r.origin.X + r.corner.X) / 2;
  12.     int y = (r.origin.Y + r.corner.Y) / 2;
  13.     bar(r, (int)pColorSet->colors.BAK_COLOR,
  14.         (int)pColorSet->colors.FILL_COLOR, (uchar*)::pattern[pattern]);
  15.  
  16.     switch(type)
  17.     {
  18.         case NO_ELEMENT:
  19.             break;
  20.         case BLACK_ELEMENT: case BLUE_ELEMENT: case GREEN_ELEMENT:
  21.     case CYAN_ELEMENT:case RED_ELEMENT: case MAGENTA_ELEMENT:
  22.     case BROWN_ELEMENT: case LIGHTGRAY_ELEMENT: case DARKGRAY_ELEMENT:
  23.     case LIGHTBLUE_ELEMENT:    case LIGHTGREEN_ELEMENT:
  24.     case LIGHTCYAN_ELEMENT: case LIGHTRED_ELEMENT:
  25.         case LIGHTMAGENTA_ELEMENT: case YELLOW_ELEMENT:
  26.     case WHITE_ELEMENT:
  27.         setfillstyle(SOLID_FILL, type - BLACK_ELEMENT);
  28.         bar(rect(r.origin + 3, r.corner - 3));
  29.         break;
  30.     case HOME_ELEMENT:
  31.         line(x, y,
  32.          r.corner.X - area[border_type].corner.X, y);
  33.         line(x, y, r.corner.X - area[border_type].corner.X,
  34.          r.origin.Y + area[border_type].origin.Y);
  35.         line(x, y, r.corner.X - area[border_type].corner.X,
  36.          r.corner.Y - area[border_type].corner.Y);
  37.         line(x, r.origin.Y + area[border_type].origin.Y,
  38.          x, r.corner.Y - area[border_type].corner.Y);
  39.         break;
  40.     case END_ELEMENT:
  41.         line(r.origin.X + area[border_type].origin.X, y,
  42.          x, y);
  43.         line(x, y, r.origin.X + area[border_type].origin.X,
  44.          r.origin.Y + area[border_type].origin.Y);
  45.         line(x, y, r.origin.X + area[border_type].origin.X,
  46.          r.corner.Y - area[border_type].corner.Y);
  47.         line(x, r.origin.Y + area[border_type].origin.Y,
  48.          x, r.corner.Y - area[border_type].corner.Y);
  49.         break;
  50.  
  51.     case LEFT_ELEMENT:
  52.         line(r.origin.X + area[border_type].origin.X, y,
  53.          r.corner.X - area[border_type].corner.X, y);
  54.         line(r.origin.X + area[border_type].origin.X, y,
  55.          x, r.origin.Y + area[border_type].origin.Y);
  56.         line(r.origin.X + area[border_type].origin.X, y,
  57.          x, r.corner.Y - area[border_type].corner.Y);
  58.         break;
  59.     case RIGHT_ELEMENT:
  60.         line(r.origin.X + area[border_type].origin.X, y,
  61.          r.corner.X - area[border_type].corner.X, y);
  62.         line(r.corner.X - area[border_type].corner.X, y,
  63.          x, r.corner.Y - area[border_type].corner.Y);
  64.         line(r.corner.X - area[border_type].corner.X, y,
  65.          x, r.origin.Y + area[border_type].origin.Y);
  66.         break;
  67.     case MOVE_ELEMENT:
  68.         line(r.origin.X + area[border_type].origin.X, y,
  69.          r.corner.X - area[border_type].corner.X, y);
  70.         line(r.origin.X + area[border_type].origin.X, y,
  71.          x, r.origin.Y + area[border_type].origin.Y);
  72.         line(r.corner.X - area[border_type].corner.X, y,
  73.          x, r.corner.Y - area[border_type].corner.Y);
  74.         break;
  75.     case RESIZE_ELEMENT:
  76.         line(r.origin.X + area[border_type].origin.X,
  77.          r.origin.Y + area[border_type].origin.Y,
  78.          r.corner.X - area[border_type].corner.X,
  79.          r.corner.Y - area[border_type].corner.Y);
  80.          line(r.corner.X - area[border_type].corner.X,
  81.           r.corner.Y - area[border_type].corner.Y,
  82.           x, r.corner.Y - area[border_type].corner.Y);
  83.          line(r.corner.X - area[border_type].corner.X,
  84.           r.corner.Y - area[border_type].corner.Y,
  85.           r.corner.X - area[border_type].corner.X, y);
  86.          break;
  87.     case UP_ELEMENT:
  88.         line(x, r.origin.Y + area[border_type].origin.Y,
  89.          x, r.corner.Y - area[border_type].corner.Y);
  90.         line(r.origin.X + area[border_type].origin.X, y,
  91.          x, r.origin.Y + area[border_type].origin.Y);
  92.         line(r.corner.X - area[border_type].corner.X, y,
  93.          x, r.origin.Y + area[border_type].origin.Y);
  94.         break;
  95.     case DN_ELEMENT:
  96.         line(x, r.origin.Y + area[border_type].origin.Y,
  97.          x, r.corner.Y - area[border_type].corner.Y);
  98.         line(r.corner.X - area[border_type].corner.X, y,
  99.          x, r.corner.Y - area[border_type].corner.Y);
  100.         line(r.origin.X + area[border_type].origin.X, y,
  101.          x, r.corner.Y - area[border_type].corner.Y);
  102.         break;
  103.     case PG_UP_ELEMENT:
  104.         line(x, r.origin.Y + area[border_type].origin.Y,
  105.          x, r.corner.Y - area[border_type].corner.Y);
  106.         line(r.origin.X + area[border_type].origin.X, y,
  107.          x, r.origin.Y + area[border_type].origin.Y);
  108.         line(r.corner.X - area[border_type].corner.X, y,
  109.          x, r.origin.Y + area[border_type].origin.Y);
  110.         line(r.origin.X + area[border_type].origin.X,
  111.         r.corner.Y - area[border_type].corner.Y, x, y);
  112.         line(x, y,
  113.          r.corner.X - area[border_type].corner.X,
  114.          r.corner.Y - area[border_type].corner.Y);
  115.         break;
  116.     case PG_DN_ELEMENT:
  117.         line(x, r.origin.Y + area[border_type].origin.Y,
  118.          x, r.corner.Y - area[border_type].corner.Y);
  119.         line(r.corner.X - area[border_type].corner.X, y,
  120.          x, r.corner.Y - area[border_type].corner.Y);
  121.         line(r.origin.X + area[border_type].origin.X, y,
  122.          x, r.corner.Y - area[border_type].corner.Y);
  123.         line(r.origin.X + area[border_type].origin.X,
  124.          r.origin.Y + area[border_type].origin.Y,
  125.          x, y);
  126.         line(x, y,
  127.          r.corner.X - area[border_type].corner.X,
  128.          r.origin.Y + area[border_type].origin.Y);
  129.         break;
  130.     case CANCEL_ELEMENT:
  131.         line(r.origin.X, r.origin.Y, r.corner.X, r.corner.Y);
  132.         line(r.corner.X, r.origin.Y, r.origin.X, r.corner.Y);
  133.         break;
  134.     case OK_ELEMENT:
  135.         circle(x, y,
  136.         (r.width() - area[border_type].origin.X
  137.             - area[border_type].corner.X) / 3);
  138.         break;
  139.         default:
  140.             break;
  141.     }
  142.     Frame::show();
  143.     }
  144. //////////////////////////
  145. /*
  146. void main()
  147.     {
  148.     if(!init_KNOW_HOW())
  149.         return;
  150.     setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
  151.     bar(0, 0, getmaxx(), getmaxy());
  152.  
  153.     Element e(rect(1, 1, 15, 6), OK_ELEMENT, BUTTON_BORDER);
  154.     e.show();
  155.     e.exe();
  156.  
  157.     close_KNOW_HOW();
  158.     closegraph();
  159.     }
  160. */